home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / nt / lkbackup.zip / nt.h < prev    next >
C/C++ Source or Header  |  1993-10-25  |  8KB  |  300 lines

  1. // I pulled this stuff from the NT port of Tar. That author had pulled
  2. // it from the NT port of Perl. This stuff is getting around.
  3.  
  4. /* $Id: nt.h,v 1.4 1993/09/17 02:21:00 ESullivan Exp ESullivan $ 
  5. */
  6.  
  7. /*
  8.  *  Copyright (c) 1993, Intergraph Corporation
  9.  *
  10.  *  You may distribute under the terms of either the GNU General Public
  11.  *  License or the Artistic License, as specified in the perl README file.
  12.  *
  13.  *  I pulled this out of the PERL NT port (the memory functions came
  14.  *  from PERL itself (v 4.036).  Clark Williams of Intergraph wrote
  15.  *  the original of this, and I apologize to him in advance for hacking
  16.  *  it all up.  :-)
  17.  *
  18.  */
  19.  
  20. /* $Log: nt.h,v $
  21.  * Revision 1.4  1993/09/17  02:21:00  ESullivan
  22.  * Consolidated this file among several projects, so that all the
  23.  * projects use the same nt.h file.
  24.  *
  25.  * Revision 1.3  1993/09/07  02:09:30  ESullivan
  26.  * added a $Log area.
  27.  *
  28.  * Revision 1.2  1993/09/06  04:11:58  ESullivan
  29.  * Took out references to my fake pipe and vfork. They
  30.  * are no longer used.
  31.  *
  32.  * Revision 1.1  1993/09/05  04:59:21  ESullivan
  33.  * Initial revision
  34.  * */
  35.  
  36. //
  37. // Definitions for NT port of Perl
  38. //
  39.  
  40. //
  41. // GRRRR!!!!  Windows Nonsense.
  42. // Define the following so we don't get tons of extra stuff
  43. // when we include windows.h 
  44. //
  45.  
  46. #ifndef NT_INC
  47. #define NT_INC
  48.  
  49. #define NOGDICAPMASKS     
  50. #define NOVIRTUALKEYCODES 
  51. #define NOWINMESSAGES     
  52. #define NOWINSTYLES       
  53. #define NOSYSMETRICS      
  54. #define NOMENUS           
  55. #define NOICONS           
  56. #define NOKEYSTATES       
  57. #define NOSYSCOMMANDS     
  58. #define NORASTEROPS       
  59. #define NOSHOWWINDOW      
  60. #define OEMRESOURCE       
  61. #define NOATOM            
  62. #define NOCLIPBOARD       
  63. #define NOCOLOR           
  64. #define NOCTLMGR          
  65. #define NODRAWTEXT        
  66. #define NOGDI             
  67. #define NONLS             
  68. #define NOMB              
  69. #define NOMEMMGR          
  70. #define NOMETAFILE        
  71. #define NOMINMAX          
  72. #define NOMSG             
  73. #define NOOPENFILE        
  74. #define NOSCROLL          
  75. #define NOSERVICE         
  76. #define NOSOUND           
  77. #define NOTEXTMETRIC      
  78. #define NOWH              
  79. #define NOWINOFFSETS      
  80. #define NOCOMM            
  81. #define NOKANJI           
  82. #define NOHELP            
  83. #define NOPROFILER        
  84. #define NODEFERWINDOWPOS  
  85.  
  86.  
  87. //
  88. // Ok now we can include the normal include files.
  89. //
  90. #include <stdio.h>
  91. #ifndef GAWK
  92. #include <stdarg.h>
  93. #endif /* !GAWK */
  94.  
  95. #ifndef DIFF3
  96. #ifndef GAWK
  97. #include <windows.h>
  98. #endif /* GAWK */
  99. #endif /* not DIFF3 */
  100.  
  101. #define bool int
  102. #define MEM_SIZE size_t
  103. typedef MEM_SIZE STRLEN;
  104.  
  105. //
  106. // We\'re not using Microsoft\'s "extensions" to C for
  107. // Structured Exception Handling (SEH) so we can nuke these
  108. //
  109. #undef try
  110. #undef except
  111. #undef finally
  112. #undef leave
  113.  
  114. #ifndef DIFF3
  115. #include <winsock.h>
  116. #endif /* not DIFF3 */
  117.  
  118. #include <sys/types.h>
  119. #include <direct.h>
  120. #include <process.h>
  121. #include <io.h>
  122. #include <time.h>
  123. #include <sys/utime.h>
  124.  
  125. //
  126. // Grrr...
  127. //
  128.  
  129. #define access       _access
  130. #define chmod       _chmod
  131. #define chsize       _chsize
  132. #define close       _close
  133. #define creat       _creat
  134. #define dup       _dup
  135. // #define dup2       _dup2
  136. #define eof       _eof
  137. #define filelength _filelength
  138. #define isatty       _isatty
  139. #define locking    _locking
  140. #define lseek       _lseek
  141. #define mktemp       _mktemp
  142. #define open       _open
  143. #define read       _read
  144. #define setmode    _setmode
  145. #define sopen       _sopen
  146. #define tell       _tell
  147. #define umask       _umask
  148. #define unlink       _unlink
  149. #define write       _write
  150. #define execl       _execl
  151. #define execle       _execle
  152. #define execlp       _execlp
  153. #define execlpe    _execlpe
  154. #define execv       _execv
  155. #define execve       _execve
  156. #define execvp       _execvp
  157. #define execvpe    _execvpe
  158. #define getpid       _getpid
  159. #define spawnl       _spawnl
  160. #define spawnle    _spawnle
  161. #define spawnlp    _spawnlp
  162. #define spawnlpe   _spawnlpe
  163. #define spawnv       _spawnv
  164. #define spawnve    _spawnve
  165. #define spawnvp    _spawnvp
  166. #define spawnvpe   _spawnvpe
  167. #define cwait       _cwait
  168. #define fileno       _fileno
  169. #define utime      _utime
  170.  
  171. //
  172. // This is for the memory functions swiped from PERL...
  173. //
  174. #define FLUSH   ;fflush( stderr )
  175. #define MEM_SIZE size_t
  176. #define Nullch  (char*)0
  177. #define New(x,v,n,t)  (v = (t*)safemalloc(((unsigned long)(n) * sizeof(t))))
  178. #define Newc(x,v,n,t,c)  (v = (c*)safemalloc(((unsigned long)(n) * sizeof(t))))
  179. #define Newz(x,v,n,t) (v = (t*)safemalloc(((unsigned long)(n) * sizeof(t)))), \
  180.     memzero((char*)(v), (n) * sizeof(t))
  181. #define Renew(v,n,t) (v = (t*)saferealloc((char*)(v),((unsigned long)(n)*sizeof(t))))
  182. #define Renewc(v,n,t,c) (v = (c*)saferealloc((char*)(v),((unsigned long)(n)*sizeof(t))))
  183.  
  184. #define Safefree(d) safefree((char*)d)
  185. #define Str_new(x,len) str_new(len)
  186.  
  187. char    *safemalloc();
  188. char    *saferealloc();
  189. void    safefree();
  190. void    *memzero();
  191.  
  192.  
  193. //
  194. // Got the idea and some of the code from the MSDOS implementation
  195. //
  196.  
  197. /* 
  198.  *    (C) Copyright 1987, 1990 Diomidis Spinellis.
  199.  *
  200.  *    You may distribute under the terms of either the GNU General Public
  201.  *    License or the Artistic License, as specified in the README file.
  202.  *
  203.  * Included in the nt header file for use by nt port
  204.  *
  205.  */
  206. /*
  207.  * defines the type returned by the directory(3) functions
  208.  */
  209.  
  210. /*Directory entry size */
  211. #ifdef DIRSIZ
  212. #undef DIRSIZ
  213. #endif
  214. #define DIRSIZ(rp)    (sizeof(struct direct))
  215.  
  216. /* need this so that directory stuff will compile! */
  217. //#define DIRENT direct
  218.  
  219. /*
  220.  * Structure of a directory entry
  221.  */
  222. #ifndef DIRECT_DEFINED
  223. struct direct    {
  224.     ino_t    d_ino;            /* inode number (not used by MS-DOS) */
  225.     int    d_namlen;        /* Name length */
  226.     char    d_name[257];        /* file name */
  227. };
  228.  
  229. #define DIRECT_DEFINED
  230. #endif
  231.  
  232. #ifndef DIRSTRUCT_DEFINED
  233. struct _dir_struc {            /* Structure used by dir operations */
  234.     char *start;            /* Starting position */
  235.     char *curr;            /* Current position */
  236.     long size;            /* Size of string table */
  237.     long nfiles;            /* number if filenames in table */
  238.     struct direct dirstr;        /* Directory structure to return */
  239. };
  240.  
  241. #define DIRSTRUCT_DEFINED
  242. #endif
  243.  
  244. typedef struct _dir_struc DIR;        /* Type returned by dir operations */
  245.  
  246.  
  247. extern int sys_nerr;
  248. extern char *sys_errlist[];
  249.  
  250. // #define strerror(e) mystrerror(e)
  251.  
  252. /*
  253.  * Here\'s some voodoo to prevent winsock initialization until it\'s 
  254.  * actually required.
  255.  *
  256.  */
  257. #define accept myaccept
  258. #define bind mybind
  259. #define connect myconnect
  260. #define getpeername mygetpeername
  261. #define getsockname mygetsockname
  262. #define getsockopt mygetsockopt
  263. #define ioctlsocket myioctlsocket
  264. #define listen mylisten
  265. #define recv myrecv
  266. #define recvfrom myrecvfrom
  267. #define select myselect
  268. #define send mysend
  269. #define sendto mysendto
  270. #define setsockopt mysetsockopt
  271. #define shutdown myshutdown
  272. #define socket mysocket
  273. #define gethostbyaddr mygethostbyaddr
  274. #define gethostbyname mygethostbyname
  275. #define gethostname mygethostname
  276. #define getprotobyname mygetprotobyname
  277. #define getprotobynumber mygetprotobynumber
  278. #define getservbyname mygetservbyname
  279. #define getservbyport mygetservbyport
  280.  
  281. // function prototypes
  282. DIR *cdecl opendir(char *filename);
  283. struct direct *readdir(DIR *dirp);
  284. long telldir(DIR *dirp);
  285. void seekdir(DIR *dirp,long loc);
  286. void rewinddir(DIR *dirp);
  287. void closedir(DIR *dirp);
  288.  
  289. // functions in ntpipe.c
  290. bool NtHasRedirection (char *cmd);
  291. int NtMakeCmdVector (char *cmdline, char ***vec, int InputCmd);
  292. FILE *ntpopen (char *cmd, char *mode);
  293. FILE *ntpopenEx (char *cmd, char *mode, int *cpipes); 
  294. int ntpclose(FILE *fp); 
  295. int ntGetPid( FILE *fp);
  296. int ntwait_for( int pid);
  297.  
  298. #endif //NT_INC
  299.  
  300.